import numpy as np

from mainmethod import *

if __name__ == '__main__':

    # ecfinal = 10000
    flag =0
    ecfinal = np.ceil(0.5 * 512 * 512)
    k = 16
    Img = Load_img('test')
    img = Img[0]
    imgs = copy.deepcopy(img)
    img_hide, RateList = danci(imgs, flag, k, ecfinal)
    new_img = copy.deepcopy(img_hide)
    print('ec', RateList)
    if int(np.sum(RateList)) == 0:
        print('第二次插入')
        k = 16
        flags = 1
        new_img, ec = danci(new_img, flags, k, ecfinal)
        # pd.DataFrame(new_img).to_csv('./newimg.csv')
        psnr = cal_psnr(img, new_img, ec)
        print('psnr', psnr)
    # x_size = np.linspace(0.01, 0.17, 17)
    # y_size = np.zeros(17)
    # index = 0
    # print(x_size)
    # for i in range(len(x_size)):
    #     flag = 0
    #     print("第{}论".format(i))
    #     ecfinal = np.ceil(x_size[i] * 512 * 512)
    #     k = 16
    #     Img = Load_img('test')
    #     img = Img[0]
    #     imgs = copy.deepcopy(img)
    #     img_hide, RateList = danci(imgs, flag, k, ecfinal)
    #     new_img = copy.deepcopy(img_hide)
    #     print('ec', RateList)
    #     if int(np.sum(RateList)) == 0:
    #         print('第二次插入')
    #         k = 16
    #         flags = 1
    #         new_img, ec = danci(new_img, flags, k, ecfinal)
    #         # pd.DataFrame(new_img).to_csv('./newimg.csv')
    #         psnr = cal_psnr(img, new_img, ec)
    #         print('psnr', psnr)
    #         y_size[index] = psnr
    #         index += 1
    # pd.DataFrame(y_size).to_csv('./psnr.csv')
    # plt_make(y_size)
